package com.xm.utils.common;

import java.util.Map;
import java.util.Objects;

public class ParamUtil {
    /**
     * 将map转换为排序参数字符串
     *
     * @param param
     * @return
     */
    public static String toSortStr(Map<String, ?> param) {
        if (param == null || param.size() == 0) {
            return "";
        }
        return param.entrySet()
                .stream()
                .sorted(Map.Entry.comparingByKey())
                .map(Objects::toString)
                .reduce((s1, s2) -> s1 + "&" + s2)
                .get();
    }
}
